<?php
/**
 * Created by PhpStorm.
 * User: bg
 * Date: 2017/8/26 0026
 * Time: 下午 2:08
 */
namespace app\common\model;
use think\Model;
use think\Loader;
use think\Db;
/*
 * 公告模型
 */
class Notice extends Model{
    //添加公告
    public function add($data){
        $ret = $this->insertGetId($data);
        return $ret;
    }
    //删除公告
    public function del($id){
        $map['announcement_id'] = $id;
        $ret = $this->where($map)->delete();
        return $ret;
    }
    //修改公告
    public function mod($id,$data){
        $map['announcement_id'] = $id;
        $ret = $this->where($map)->update($data);
        return $ret;
    }
    //根据ID查询公告
    public function search($id){
        $map['announcement_id'] = $id;
        $ret = $this->where($map)->find();
        return $ret;
    }
    //查询所有公告
    public function getlist(){
        $ret = $this->select();
        return $ret;
    }
    //根据条件获取公告列表
    public function getAll($map,$field='*',$Nowpage=1, $limits=10)
    {
        return $this->where($map)->field($field)->page($Nowpage,$limits)->order('create_time desc')->select();
    }
    //统计公告条数
    public function count($map){
        return $this->where($map)->count();
    }


}